Optimal. Leaf size=178 \[ -\frac {\left (a^2+2 b^2\right ) (b B-a C) x}{2 a^4}+\frac {2 b^3 (b B-a C) \tanh ^{-1}\left (\frac {\sqrt {a-b} \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a+b}}\right )}{a^4 \sqrt {a-b} \sqrt {a+b} d}+\frac {\left (2 a^2 B+3 b^2 B-3 a b C\right ) \sin (c+d x)}{3 a^3 d}-\frac {(b B-a C) \cos (c+d x) \sin (c+d x)}{2 a^2 d}+\frac {B \cos ^2(c+d x) \sin (c+d x)}{3 a d} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.50, antiderivative size = 178, normalized size of antiderivative = 1.00, number of steps
used = 8, number of rules used = 7, integrand size = 40, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.175, Rules used = {4157, 4119,
4189, 4004, 3916, 2738, 214} \begin {gather*} \frac {2 b^3 (b B-a C) \tanh ^{-1}\left (\frac {\sqrt {a-b} \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a+b}}\right )}{a^4 d \sqrt {a-b} \sqrt {a+b}}-\frac {(b B-a C) \sin (c+d x) \cos (c+d x)}{2 a^2 d}-\frac {x \left (a^2+2 b^2\right ) (b B-a C)}{2 a^4}+\frac {\left (2 a^2 B-3 a b C+3 b^2 B\right ) \sin (c+d x)}{3 a^3 d}+\frac {B \sin (c+d x) \cos ^2(c+d x)}{3 a d} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 214
Rule 2738
Rule 3916
Rule 4004
Rule 4119
Rule 4157
Rule 4189
Rubi steps
\begin {align*} \int \frac {\cos ^4(c+d x) \left (B \sec (c+d x)+C \sec ^2(c+d x)\right )}{a+b \sec (c+d x)} \, dx &=\int \frac {\cos ^3(c+d x) (B+C \sec (c+d x))}{a+b \sec (c+d x)} \, dx\\ &=\frac {B \cos ^2(c+d x) \sin (c+d x)}{3 a d}-\frac {\int \frac {\cos ^2(c+d x) \left (3 (b B-a C)-2 a B \sec (c+d x)-2 b B \sec ^2(c+d x)\right )}{a+b \sec (c+d x)} \, dx}{3 a}\\ &=-\frac {(b B-a C) \cos (c+d x) \sin (c+d x)}{2 a^2 d}+\frac {B \cos ^2(c+d x) \sin (c+d x)}{3 a d}+\frac {\int \frac {\cos (c+d x) \left (2 \left (2 a^2 B+3 b^2 B-3 a b C\right )+a (b B+3 a C) \sec (c+d x)-3 b (b B-a C) \sec ^2(c+d x)\right )}{a+b \sec (c+d x)} \, dx}{6 a^2}\\ &=\frac {\left (2 a^2 B+3 b^2 B-3 a b C\right ) \sin (c+d x)}{3 a^3 d}-\frac {(b B-a C) \cos (c+d x) \sin (c+d x)}{2 a^2 d}+\frac {B \cos ^2(c+d x) \sin (c+d x)}{3 a d}-\frac {\int \frac {3 \left (a^2+2 b^2\right ) (b B-a C)+3 a b (b B-a C) \sec (c+d x)}{a+b \sec (c+d x)} \, dx}{6 a^3}\\ &=-\frac {\left (a^2+2 b^2\right ) (b B-a C) x}{2 a^4}+\frac {\left (2 a^2 B+3 b^2 B-3 a b C\right ) \sin (c+d x)}{3 a^3 d}-\frac {(b B-a C) \cos (c+d x) \sin (c+d x)}{2 a^2 d}+\frac {B \cos ^2(c+d x) \sin (c+d x)}{3 a d}+\frac {\left (b^3 (b B-a C)\right ) \int \frac {\sec (c+d x)}{a+b \sec (c+d x)} \, dx}{a^4}\\ &=-\frac {\left (a^2+2 b^2\right ) (b B-a C) x}{2 a^4}+\frac {\left (2 a^2 B+3 b^2 B-3 a b C\right ) \sin (c+d x)}{3 a^3 d}-\frac {(b B-a C) \cos (c+d x) \sin (c+d x)}{2 a^2 d}+\frac {B \cos ^2(c+d x) \sin (c+d x)}{3 a d}+\frac {\left (b^2 (b B-a C)\right ) \int \frac {1}{1+\frac {a \cos (c+d x)}{b}} \, dx}{a^4}\\ &=-\frac {\left (a^2+2 b^2\right ) (b B-a C) x}{2 a^4}+\frac {\left (2 a^2 B+3 b^2 B-3 a b C\right ) \sin (c+d x)}{3 a^3 d}-\frac {(b B-a C) \cos (c+d x) \sin (c+d x)}{2 a^2 d}+\frac {B \cos ^2(c+d x) \sin (c+d x)}{3 a d}+\frac {\left (2 b^2 (b B-a C)\right ) \text {Subst}\left (\int \frac {1}{1+\frac {a}{b}+\left (1-\frac {a}{b}\right ) x^2} \, dx,x,\tan \left (\frac {1}{2} (c+d x)\right )\right )}{a^4 d}\\ &=-\frac {\left (a^2+2 b^2\right ) (b B-a C) x}{2 a^4}+\frac {2 b^3 (b B-a C) \tanh ^{-1}\left (\frac {\sqrt {a-b} \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a+b}}\right )}{a^4 \sqrt {a-b} \sqrt {a+b} d}+\frac {\left (2 a^2 B+3 b^2 B-3 a b C\right ) \sin (c+d x)}{3 a^3 d}-\frac {(b B-a C) \cos (c+d x) \sin (c+d x)}{2 a^2 d}+\frac {B \cos ^2(c+d x) \sin (c+d x)}{3 a d}\\ \end {align*}
________________________________________________________________________________________
Mathematica [A]
time = 0.52, size = 152, normalized size = 0.85 \begin {gather*} \frac {6 \left (a^2+2 b^2\right ) (-b B+a C) (c+d x)-\frac {24 b^3 (b B-a C) \tanh ^{-1}\left (\frac {(-a+b) \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a^2-b^2}}\right )}{\sqrt {a^2-b^2}}+3 a \left (3 a^2 B+4 b^2 B-4 a b C\right ) \sin (c+d x)+3 a^2 (-b B+a C) \sin (2 (c+d x))+a^3 B \sin (3 (c+d x))}{12 a^4 d} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A]
time = 0.26, size = 242, normalized size = 1.36
method | result | size |
derivativedivides | \(\frac {-\frac {2 \left (\frac {\left (-a^{3} B -\frac {1}{2} a^{2} b B -a \,b^{2} B +\frac {1}{2} a^{3} C +a^{2} b C \right ) \left (\tan ^{5}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )+\left (-\frac {2}{3} a^{3} B -2 a \,b^{2} B +2 a^{2} b C \right ) \left (\tan ^{3}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )+\left (-a^{3} B -a \,b^{2} B +a^{2} b C +\frac {1}{2} a^{2} b B -\frac {1}{2} a^{3} C \right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{\left (1+\tan ^{2}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )^{3}}+\frac {\left (a^{2} b B +2 b^{3} B -a^{3} C -2 C \,b^{2} a \right ) \arctan \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{2}\right )}{a^{4}}+\frac {2 b^{3} \left (b B -a C \right ) \arctanh \left (\frac {\left (a -b \right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{\sqrt {\left (a +b \right ) \left (a -b \right )}}\right )}{a^{4} \sqrt {\left (a +b \right ) \left (a -b \right )}}}{d}\) | \(242\) |
default | \(\frac {-\frac {2 \left (\frac {\left (-a^{3} B -\frac {1}{2} a^{2} b B -a \,b^{2} B +\frac {1}{2} a^{3} C +a^{2} b C \right ) \left (\tan ^{5}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )+\left (-\frac {2}{3} a^{3} B -2 a \,b^{2} B +2 a^{2} b C \right ) \left (\tan ^{3}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )+\left (-a^{3} B -a \,b^{2} B +a^{2} b C +\frac {1}{2} a^{2} b B -\frac {1}{2} a^{3} C \right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{\left (1+\tan ^{2}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )^{3}}+\frac {\left (a^{2} b B +2 b^{3} B -a^{3} C -2 C \,b^{2} a \right ) \arctan \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{2}\right )}{a^{4}}+\frac {2 b^{3} \left (b B -a C \right ) \arctanh \left (\frac {\left (a -b \right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{\sqrt {\left (a +b \right ) \left (a -b \right )}}\right )}{a^{4} \sqrt {\left (a +b \right ) \left (a -b \right )}}}{d}\) | \(242\) |
risch | \(-\frac {x b B}{2 a^{2}}-\frac {x \,b^{3} B}{a^{4}}+\frac {x C}{2 a}+\frac {x C \,b^{2}}{a^{3}}-\frac {3 i B \,{\mathrm e}^{i \left (d x +c \right )}}{8 a d}+\frac {i b \,{\mathrm e}^{i \left (d x +c \right )} C}{2 a^{2} d}+\frac {3 i B \,{\mathrm e}^{-i \left (d x +c \right )}}{8 a d}-\frac {i b \,{\mathrm e}^{-i \left (d x +c \right )} C}{2 a^{2} d}+\frac {i {\mathrm e}^{-i \left (d x +c \right )} b^{2} B}{2 a^{3} d}-\frac {i {\mathrm e}^{i \left (d x +c \right )} b^{2} B}{2 a^{3} d}+\frac {b^{4} \ln \left ({\mathrm e}^{i \left (d x +c \right )}+\frac {i a^{2}-i b^{2}+\sqrt {a^{2}-b^{2}}\, b}{a \sqrt {a^{2}-b^{2}}}\right ) B}{\sqrt {a^{2}-b^{2}}\, d \,a^{4}}-\frac {b^{3} \ln \left ({\mathrm e}^{i \left (d x +c \right )}+\frac {i a^{2}-i b^{2}+\sqrt {a^{2}-b^{2}}\, b}{a \sqrt {a^{2}-b^{2}}}\right ) C}{\sqrt {a^{2}-b^{2}}\, d \,a^{3}}-\frac {b^{4} \ln \left ({\mathrm e}^{i \left (d x +c \right )}+\frac {-i a^{2}+i b^{2}+\sqrt {a^{2}-b^{2}}\, b}{a \sqrt {a^{2}-b^{2}}}\right ) B}{\sqrt {a^{2}-b^{2}}\, d \,a^{4}}+\frac {b^{3} \ln \left ({\mathrm e}^{i \left (d x +c \right )}+\frac {-i a^{2}+i b^{2}+\sqrt {a^{2}-b^{2}}\, b}{a \sqrt {a^{2}-b^{2}}}\right ) C}{\sqrt {a^{2}-b^{2}}\, d \,a^{3}}+\frac {B \sin \left (3 d x +3 c \right )}{12 a d}-\frac {\sin \left (2 d x +2 c \right ) b B}{4 a^{2} d}+\frac {\sin \left (2 d x +2 c \right ) C}{4 a d}\) | \(511\) |
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [F(-2)]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {Exception raised: ValueError} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [A]
time = 3.26, size = 547, normalized size = 3.07 \begin {gather*} \left [\frac {3 \, {\left (C a^{5} - B a^{4} b + C a^{3} b^{2} - B a^{2} b^{3} - 2 \, C a b^{4} + 2 \, B b^{5}\right )} d x - 3 \, {\left (C a b^{3} - B b^{4}\right )} \sqrt {a^{2} - b^{2}} \log \left (\frac {2 \, a b \cos \left (d x + c\right ) - {\left (a^{2} - 2 \, b^{2}\right )} \cos \left (d x + c\right )^{2} + 2 \, \sqrt {a^{2} - b^{2}} {\left (b \cos \left (d x + c\right ) + a\right )} \sin \left (d x + c\right ) + 2 \, a^{2} - b^{2}}{a^{2} \cos \left (d x + c\right )^{2} + 2 \, a b \cos \left (d x + c\right ) + b^{2}}\right ) + {\left (4 \, B a^{5} - 6 \, C a^{4} b + 2 \, B a^{3} b^{2} + 6 \, C a^{2} b^{3} - 6 \, B a b^{4} + 2 \, {\left (B a^{5} - B a^{3} b^{2}\right )} \cos \left (d x + c\right )^{2} + 3 \, {\left (C a^{5} - B a^{4} b - C a^{3} b^{2} + B a^{2} b^{3}\right )} \cos \left (d x + c\right )\right )} \sin \left (d x + c\right )}{6 \, {\left (a^{6} - a^{4} b^{2}\right )} d}, \frac {3 \, {\left (C a^{5} - B a^{4} b + C a^{3} b^{2} - B a^{2} b^{3} - 2 \, C a b^{4} + 2 \, B b^{5}\right )} d x - 6 \, {\left (C a b^{3} - B b^{4}\right )} \sqrt {-a^{2} + b^{2}} \arctan \left (-\frac {\sqrt {-a^{2} + b^{2}} {\left (b \cos \left (d x + c\right ) + a\right )}}{{\left (a^{2} - b^{2}\right )} \sin \left (d x + c\right )}\right ) + {\left (4 \, B a^{5} - 6 \, C a^{4} b + 2 \, B a^{3} b^{2} + 6 \, C a^{2} b^{3} - 6 \, B a b^{4} + 2 \, {\left (B a^{5} - B a^{3} b^{2}\right )} \cos \left (d x + c\right )^{2} + 3 \, {\left (C a^{5} - B a^{4} b - C a^{3} b^{2} + B a^{2} b^{3}\right )} \cos \left (d x + c\right )\right )} \sin \left (d x + c\right )}{6 \, {\left (a^{6} - a^{4} b^{2}\right )} d}\right ] \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \int \frac {\left (B + C \sec {\left (c + d x \right )}\right ) \cos ^{4}{\left (c + d x \right )} \sec {\left (c + d x \right )}}{a + b \sec {\left (c + d x \right )}}\, dx \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [B] Leaf count of result is larger than twice the leaf count of optimal. 360 vs.
\(2 (161) = 322\).
time = 0.49, size = 360, normalized size = 2.02 \begin {gather*} \frac {\frac {3 \, {\left (C a^{3} - B a^{2} b + 2 \, C a b^{2} - 2 \, B b^{3}\right )} {\left (d x + c\right )}}{a^{4}} - \frac {12 \, {\left (C a b^{3} - B b^{4}\right )} {\left (\pi \left \lfloor \frac {d x + c}{2 \, \pi } + \frac {1}{2} \right \rfloor \mathrm {sgn}\left (-2 \, a + 2 \, b\right ) + \arctan \left (-\frac {a \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )}{\sqrt {-a^{2} + b^{2}}}\right )\right )}}{\sqrt {-a^{2} + b^{2}} a^{4}} + \frac {2 \, {\left (6 \, B a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{5} - 3 \, C a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{5} + 3 \, B a b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{5} - 6 \, C a b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{5} + 6 \, B b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{5} + 4 \, B a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} - 12 \, C a b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} + 12 \, B b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} + 6 \, B a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 3 \, C a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 3 \, B a b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 6 \, C a b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 6 \, B b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )\right )}}{{\left (\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} + 1\right )}^{3} a^{3}}}{6 \, d} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [B]
time = 8.92, size = 2500, normalized size = 14.04 \begin {gather*} \text {Too large to display} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________